{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=3157
  Verdict: Accepted
}
uses SysUtils, Math;
 
const
	firstV:int64=round(1e12);
 
var
	k,kk,ls,p2,p1,ans:int64;
	s:string;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
readln(s);
ls:=length(s);
p1:=firstV;
p2:=firstV;
ans:=0;
while ls>0 do begin
	kk:=pos(' ',s);
	if kk=0 then begin
		k:=strtoint(s);
		s:='';
	end else begin
		k:=strtoint(copy(s,1,kk-1));
		delete(s,1,kk);
	end;
	if (p2<>firstV) and (p1<>firstV) and (p1>k) and (p1>p2) then inc(ans);
	p2:=p1;
	p1:=k;
	ls:=length(S);
end;
write(ans);
end.